Add built-in jq filtering - #203
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds built-in --jq filtering for structured CLI responses.
Changes:
- Integrates
gojqwith safe result rendering. - Wires global flag validation and raw-output exclusions.
- Adds documentation, help text, surface metadata, and tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.surface |
Records the new public flags. |
README.md |
Documents filtering behavior and examples. |
skills/hey/SKILL.md |
Updates agent guidance for built-in filtering. |
go.mod |
Adds filtering and ANSI dependencies. |
go.sum |
Locks new dependency checksums. |
internal/output/writer.go |
Implements filtering and terminal-safe rendering. |
internal/output/writer_test.go |
Tests filtering and output safety. |
internal/output/errors.go |
Adds typed jq errors. |
internal/cmd/root.go |
Registers and validates --jq. |
internal/cmd/jq_test.go |
Tests command integration and exclusions. |
internal/cmd/help.go |
Adds --jq to help output. |
internal/cmd/help_test.go |
Updates help expectations. |
Suppressed comments (1)
internal/cmd/root.go:227
- An explicitly supplied empty value (
--jq ''or--jq=) is treated as though the flag were absent. The earlier format selection also usesjqFlag != "", so this silently falls back to ordinary, unfiltered output instead of validating the expression or implying JSON; a script can unexpectedly receive the full response. Track flag presence withcmd.Flags().Changed("jq")separately from its value, and reject an empty expression while preserving the absent-flag case.
if filter == "" {
return nil
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HEY’s structured commands gain a built-in
--jqfilter so agents and scripts can select response data without depending on an external binary. Existing output remains unchanged unless the new flag is supplied, and commands with dedicated raw output reject it explicitly.Review readiness: ✅ Yes
Risk: 🟡 Medium — this adds a dependency and a shared output path used by every structured command
Decision: None
✅ Change — structured output can be filtered in-process
Before
After
--jqfilters the full success envelope and implies JSON output.--quiet --jqfilters data directly. Scalar strings print as text, compound values print formatted JSON, multiple results stream predictably, and error envelopes remain complete.Raw-output paths (
auth token,completion, skill display, the TUI, and--version) reject--jqrather than silently ignoring it.✅ Evidence — behavior, safety boundaries, and compatibility are covered
ac9d4b1, replied to, and resolved with focused regressions.✅ Scope — existing output is preserved unless --jq is requested
Included:
--jqparsing, validation, and helpNot included:
--json,--quiet, or styled output--jqto raw token, script, document, version, or TUI output➖ Delivery — no migration, configuration, or rollout work
gojqis linked into the existing Go binary. There are no migrations, feature flags, credentials, backfills, or deploy-order requirements. Rollback is a normal revert of this commit.✅ Review decision — no unresolved product decision
Start with output semantics and terminal-safe rendering. Confirm that filtering only successful structured responses, while retaining complete error envelopes and rejecting dedicated raw formats, is the right boundary.
✅ Review path — output flow first, then regression coverage and user guidance
internal/output/writer.goandinternal/output/errors.go— filter execution, rendering, safety, and errors.internal/cmd/root.goandinternal/cmd/local_config_trust.go— global flag wiring, raw-command boundaries, and machine-output trust behavior.internal/output/writer_test.go,internal/cmd/jq_test.go, andinternal/cmd/local_config_trust_test.go— behavioral and security regressions.README.md,skills/hey/SKILL.md,go.mod,.surface, and help coverage — guidance, dependency, and public surface.Origin and supporting links: Basecamp card